package cn.edu.xmist.springmvcconcurrentdemo.remote.service.impl;

import cn.edu.xmist.springmvcconcurrentdemo.remote.service.RemoteOrderService;
import cn.edu.xmist.springmvcconcurrentdemo.service.OrderService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zhongjinbin 2021/3/26
 * @since
 */
// 模拟远程订单服务
@Service
public class RemoteOrderServiceImpl implements RemoteOrderService {
    @Override
    public Map<String, Object> queryOrderInfo(String orderCode) {
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put(orderCode, orderCode + "库存数量为1");
        return resultMap;
    }

    @Override
    public List<Map<String, Object>> queryOrderInfoByBatchOrderCode(List<Map<String, String>> batchParams) {
        List<Map<String, Object>> resultList = new ArrayList<>();
        if (batchParams != null) {
            for (Map<String, String> batchParam : batchParams) {
                Map<String, Object> resultMap = new HashMap<>();
                resultMap.put("serialNo", batchParam.get("serialNo"));
                resultMap.put("orderCode", batchParam.get("orderCode"));
                resultMap.put("qty", "1");
                resultList.add(resultMap);
            }
        }
        return resultList;
    }
}
